//测试CubeMap的像素着色器

#version 450
#extension GL_ARB_separate_shader_objects : enable

//输入-从顶点着色器
layout(location = 0) in vec3 vs_fs_normal;
layout(location = 1) in vec2 vs_fs_TexCoord;
layout(location = 2) in vec3 vs_fs_worldPosition;

//输出
layout(location = 0) out vec4 fColor;

//纹理
layout(binding = 9) uniform samplerCube ourCubeMap;

//UniformBuffer
layout(binding = 7) uniform SceneData {
	mat4 view;
	mat4 proj;
	vec4 lightDir;
	vec4 eyePosition;
} ub_SceneData;

void main()
{
	//视线方向
	vec3 EyeDir = ub_SceneData.eyePosition.xyz - vs_fs_worldPosition;
	
	//镜面反射光的方向
	vec3 LightDir = reflect(normalize(EyeDir),normalize(vs_fs_normal));
	
	//采样的方向是光线方向的反向
	vec3 SampleDir = -LightDir;
	
	//采样立方体贴图获得颜色
	fColor = texture(ourCubeMap, SampleDir);
}
